package hadoop;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;


public class WordcountReducer extends Reducer<Text, IntWritable, Text, IntWritable>{
    // 定义reduce端输出类型
    int sum;
    IntWritable v = new IntWritable();


    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws
            IOException, InterruptedException {
        // 累计
        sum = 0;
        for (IntWritable count : values){
            sum += count.get();
        }
        // 2、输出
        v.set(sum);
        context.write(key,v);
    }





}
